Skip to content

Fix invalid const-qualified function pointer in delayimp.cpp (breaks x86 clang-cl build) - #98

Merged
ethindp merged 1 commit into
ethindp:masterfrom
TomJoey:fix/x86-clang-cl-delayimp-const-auto
Aug 29, 2026
Merged

Fix invalid const-qualified function pointer in delayimp.cpp (breaks x86 clang-cl build)#98
ethindp merged 1 commit into
ethindp:masterfrom
TomJoey:fix/x86-clang-cl-delayimp-const-auto

Conversation

@TomJoey

@TomJoey TomJoey commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GetProcAddress returns FARPROC (a function pointer). The line
    if (auto const *real = GetProcAddress(...); real != nullptr) in the
    #if defined(_M_IX86) || defined(__i386__) branch of
    DelayLoadFailureHook deduces real as a pointer to a
    const-qualified function type, which isn't a meaningful
    declaration.
  • clang-cl rejects this outright when targeting x86 (-m32):
    error: variable 'real' with type 'const auto *' has incompatible
    initializer of type 'FARPROC' (aka 'int (*)() __attribute__((stdcall)))')
    
  • This branch is only compiled for _M_IX86/__i386__, and the
    project's own build-windows.yml matrix only builds x64/arm64, so
    the build break was never caught by CI.
  • Every other raw pointer in this file (e.g. the LoadLibrary results
    a few lines above, auto *const h = ...) uses auto *const — a
    non-reassignable pointer to non-const data. That's almost certainly
    what was intended here too; real is never reassigned in this
    scope. Switching to that form fixes the x86 clang-cl build without
    changing behavior (MSVC accepted the original spelling as a
    non-conforming extension).

Test plan

@ethindp

ethindp commented Aug 17, 2026

Copy link
Copy Markdown
Owner

I currently lack the energy of supporting 32-bit platforms given their increasing rarity, but I will merge this PR if the checks pass. Please note that in order for this PR to be merged you must now add your sign-off per the DCO. (I have been implementing these processes so that contributing is smoother and there is less arbitrary-ness about it.)

@ethindp

ethindp commented Aug 28, 2026

Copy link
Copy Markdown
Owner

@TomJoey Please sign-off your commit; this PR cannot be merged until you do so.

GetProcAddress returns FARPROC (a function pointer), and `auto const
*real = ...` deduces `real` as a pointer to a const-qualified function
type, which is not a meaningful/well-formed declaration. clang-cl
rejects it outright under -m32:

    error: variable 'real' with type 'const auto *' has incompatible
    initializer of type 'FARPROC'

This branch is guarded by `#if defined(_M_IX86) || defined(__i386__)`,
which the project's own Windows CI matrix (x64/arm64 only) never
builds, so the break went unnoticed. Every other pointer in this file
(e.g. the `LoadLibrary` results a few lines up) uses the `auto *const`
form instead — a non-reassignable pointer to non-const data — which is
almost certainly what was intended here too. Switching to that form
fixes the x86 clang-cl build without changing behavior.

Signed-off-by: TomJoey <tom@xztom.com>
@TomJoey
TomJoey force-pushed the fix/x86-clang-cl-delayimp-const-auto branch from 6d377e3 to ab106a6 Compare August 29, 2026 16:23
@ethindp
ethindp merged commit 6f7507b into ethindp:master Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants